#pragma once

#include "ReadLinkObjectEndQualifierAction.h"

#include "InputPin.h"
#include "OutputPin.h"
#include "Property.h"

namespace uml {

ReadLinkObjectEndQualifierAction::ReadLinkObjectEndQualifierAction(const QString& umlType)
    : Action(umlType) {}

void ReadLinkObjectEndQualifierAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    object_ = JsonSerializable::create<InputPin>(json.value("object"), errorList);

    qualifier_ = JsonSerializable::create<Property>(json.value("qualifier"), errorList);

    result_ = JsonSerializable::create<OutputPin>(json.value("result"), errorList);

}

void ReadLinkObjectEndQualifierAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    if (object_) {
        QJsonObject object_json;
        object_->toJson(object_json);
        json.insert("object", object_json);
    }
    if (qualifier_) {
        QJsonObject qualifier_json;
        qualifier_->toJson(qualifier_json);
        json.insert("qualifier", qualifier_json);
    }
    if (result_) {
        QJsonObject result_json;
        result_->toJson(result_json);
        json.insert("result", result_json);
    }
}

/// <summary>
/// object getter
/// The InputPin from which the link object is obtained.
/// </summary>
shared_ptr<InputPin> ReadLinkObjectEndQualifierAction::object() const {
    return object_;
}

/// <summary>
/// object setter
/// The InputPin from which the link object is obtained.
/// </summary>
void ReadLinkObjectEndQualifierAction::setObject(shared_ptr<InputPin> value) {
    object_ = value;
}

/// <summary>
/// qualifier getter
/// The qualifier Property to be read.
/// </summary>
shared_ptr<Property> ReadLinkObjectEndQualifierAction::qualifier() const {
    return qualifier_;
}

/// <summary>
/// qualifier setter
/// The qualifier Property to be read.
/// </summary>
void ReadLinkObjectEndQualifierAction::setQualifier(shared_ptr<Property> value) {
    qualifier_ = value;
}

/// <summary>
/// result getter
/// The OutputPin where the result value is placed.
/// </summary>
shared_ptr<OutputPin> ReadLinkObjectEndQualifierAction::result() const {
    return result_;
}

/// <summary>
/// result setter
/// The OutputPin where the result value is placed.
/// </summary>
void ReadLinkObjectEndQualifierAction::setResult(shared_ptr<OutputPin> value) {
    result_ = value;
}

} // namespace uml
